<?php

namespace Product\Controller;
use Common\Controller\HomebaseController; 
/**
 * 商品详情页
 */
class DetailController extends HomebaseController {
	
    //进入商品详情页
	public function index() {
        $id = I("get.id");
        if(empty($id)){
            die("参数有误");
        }
        $m_product = M("Products");
        $product = $m_product->where(array("id"=>$id))->find();
        $product['pictures'] = explode(',',$product['pictures']);
        foreach ($product['pictures'] as &$value) {
            $value = '/data/upload/'.$value;
        }
        $product['main_picture'] = reset($product['pictures']);
        $m_product_type = M("ProductType");
        $cat = $m_product_type->where(array('id'=>$product['tid']))->find();
        $this->assign("cat",$cat);
        $this->assign("product",$product);
        $this->assign("open_menu",false);
    	$this->display();
    }

}


